package cn.calin.day05.demo44LinkedHashMap;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;

/*
    java.util.LinkedHashMap<K,V> extends HashMap<K,V>
    Map 接口的哈希表和链接列表实现，具有可预知的迭代顺序
    底层原理：
        哈希表+链表（记录元素的顺序）
 */
public class demo01LinkedHashMap {
    public static void main(String[] args) {
        HashMap<String,String> map=new HashMap<>();
        map.put("a","a");
        map.put("c","c");
        map.put("b","b");
        map.put("a","d");
        System.out.println(map);//key不允许重复，无序{a=d, b=b, c=c}

        LinkedHashMap<String,String> linked=new LinkedHashMap<>();
        linked.put("a","a");
        linked.put("b","b");
        linked.put("d","d");
        linked.put("c","a");
        System.out.println(linked);
    }
}
